package com.hnx.admin.aurora.core.factory;

import com.hnx.admin.aurora.core.api.BuildSqlFactory;
import com.hnx.admin.aurora.core.api.BuildSqlStrategy;
import com.hnx.admin.aurora.core.func.BuildDeleteSql;
import com.hnx.admin.aurora.core.func.BuildInsertSql;
import com.hnx.admin.aurora.core.func.BuildUpdateSql;
import org.apache.ibatis.mapping.SqlCommandType;
import org.springframework.stereotype.Component;

import java.util.EnumMap;
import java.util.Map;

/*
创建人： 倔强的头发
创建时间：2025/7/3
功能描述:

*/
@Component
public class BuildSqlStrategyFactory implements BuildSqlFactory {
    private static final Map<SqlCommandType, BuildSqlStrategy> STRATEGY_MAP = new EnumMap<>(SqlCommandType.class);
    static {
        STRATEGY_MAP.put(SqlCommandType.INSERT,new BuildInsertSql());
        STRATEGY_MAP.put(SqlCommandType.UPDATE,new BuildUpdateSql());
        STRATEGY_MAP.put(SqlCommandType.DELETE,new BuildDeleteSql());
    }
    @Override
    public BuildSqlStrategy getStrategy(SqlCommandType sqlCommandType) {
        return STRATEGY_MAP.get(sqlCommandType);
    }
}
